package fr.upmc.tps.mdoc.tools;

import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import sessionBeans.GestionContactRemote;

public class ManagerEJButils<T> {

	@SuppressWarnings("unchecked")
	public T getBean(String name) {
		T bean = null;
		
		try {
			
			bean = (T) getContextNaming().lookup(name);
			
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
		return bean;
	}

	private Context getContextNaming() {

		Context context = null;

		try {

			context = new InitialContext();

		} catch (NamingException e) {
			e.printStackTrace();
		}

		return context;
	}
	
	@EJB
	private static GestionContactRemote gestionContactRemote;
	public static GestionContactRemote getGestionContactRemote()   {
		return gestionContactRemote;
	}
	
	@EJB
	private static GestionContactRemote gestionContactLocal;
	public static GestionContactRemote getGestionContactLocal()   {
		return gestionContactLocal;
	}
	
	
}
